package com.yunkuhui.www.demo.controller;

import com.yunkuhui.www.demo.model.TestUser;
import com.yunkuhui.www.demo.service.TestUserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/user")
public class TestUserController {

	@Resource
	private TestUserService testUserService;

	@RequestMapping("/1")
	public Object addUser() throws ParseException {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
		simpleDateFormat.applyPattern("yyyy-MM-dd");
		Date date = simpleDateFormat.parse("2007-9-15");
		TestUser testUser = new TestUser();
		testUser.setUserBirthday(date);
		testUser.setUserEmail("leiyunran@qq.com");
		testUser.setUserSex("m");
		testUser.setUserName("YOUQUE");
		return testUserService.saveTestUser(testUser);
	}
}
